package cn.melonlib.apis.support.model.entity;

import cn.melonlib.apis.support.model.enums.ApiOperationType;
import cn.melonlib.apis.support.model.enums.ApiRange;
import cn.melonlib.cores.commons.model.entity.TenantRecordEntity;
import cn.melonlib.cores.model.anno.ModelComment;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.*;

@Data
@EqualsAndHashCode(callSuper = true)
@Entity(name = "ApiRequestRecordIndex")
@Table(name = "apis_request_record")
@ModelComment("API请求日志")
public class ApiRequestRecordIndex extends TenantRecordEntity {

    /**
     * 本地文件存储
     */
    public static final int LOCAL_FILE=1;

    /**
     * 本地数据库存储
     */
    public static final int DB_STORE=2;

    @ModelComment("请求连接")
    @Column(length = 1000)
    private String apiUrl;

    @ModelComment("操作名称")
    private String operationName;

    @ModelComment("返回状态")
    private Integer responseCode;

    @Enumerated(EnumType.STRING)
    @ModelComment("操作类型")
    private ApiOperationType operationType= ApiOperationType.QUERY;

    @ModelComment("请求api范围")
    private String apiRange= ApiRange.IAM.name();

    @ModelComment("响应时间")
    private Long responseDateTime;

    @ModelComment("使用时间")
    private Long useTime;
}
